home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Graphics / SMan / MorphOS / Source / ULP7mos.asm < prev   
Encoding:
Assembly Source File  |  2001-03-09  |  4.9 KB  |  202 lines

  1.  
  2. #    r0        volatile, may be used by function linkage
  3. #    r1        stack pointer
  4. #    r2        table of contents register
  5. #    r3    .. r4    volatile, pass 1st - 2nd int args, return 1st - 2nd ints
  6. #    r5  .. r10    volatile, pass 3rd - 8th int args
  7. #    r11        volatile, pass static chain if language needs it
  8. #    r12        volatile, used by dyn linker, exception handling
  9. #    r13 .. r31    saved
  10.  
  11.  
  12.  
  13. #    f0        volatile
  14. #    f1  .. f4    volatile, pass 1st - 4th float args, return 1st - 4th floats
  15. #    f5  .. f13    volatile, pass 5th - 13th float args
  16. #    f14 .. f31    saved
  17.  
  18. #    Use r23    as CurCnt
  19. #    Use r24    as MaxCnt (Constant value)
  20. #    Use r25    as LPixelBuf
  21. #    Use r26    as location within ColorTable32
  22. #    Use r27    as base address of ColorTable32
  23. #    Use r28    as BPP (that is, bytes per pixel)
  24.  
  25. #    r29    as RightEdge
  26. #    r30    as xtemp (integer)
  27.  
  28.  
  29. #    Note that the following are constants, and independent of xtemp.
  30.  
  31. #    First the integers
  32. #    MaxCnt    in r24
  33. #    LPixelBuf in r25. It changes but need only be loaded 1 time.
  34. #    Base address of ColorTable32 in r27
  35. #    BPP in r28
  36.  
  37. #    Now the floats    (Newly defined)
  38.  
  39. #    3.00 in f14
  40. #    Zr in f15.  It changes as Zr is recalculated.
  41. #    Use f16    as value of yRel.  This is constant for each line.
  42. #    Use f17    Zi.  It's initially yRel, but changes within loop.
  43. #    Use f18    as xRel. Only changes as DX is added for the next pixel.
  44. #    Use f19 as |Z2| Only for comparing with Limit.
  45. #    Use f20    This is scratch and used shortly for 2Zi.
  46. #    Delta x    in f21
  47. #    Two    in f22
  48. #    Limit    in f23
  49. #    Use f24    as Zr2.  This is also a temporary value
  50. #    Use f26 as Zr3.
  51.  
  52.  
  53.     .text
  54.     .sdreg    13
  55.     .global    UseLibP7
  56.     .align    4
  57. UseLibP7:
  58.     mflr    11
  59.     stw    11,4(1)    #Save return address
  60.     stwu    1,-80(1)      #Save stack pointer
  61.     fmr    16,1        #Transfer yrel from f1 to f16
  62.     lis    4,MaxCnt@ha
  63.     lwz    24,MaxCnt@l(4)        #MaxCnt in r24.
  64.     lis    4,LPixelBuf@ha
  65.     lwz    25,LPixelBuf@l(4)    #Get Location of LPixelBuf
  66.     lis    4,ColorTable32@ha
  67.     lwz    27,ColorTable32@l(4)    #Start of color table
  68.  
  69.     lis    4,BPP@ha
  70.     lwz    28,BPP@l(4)             #Number bytes per pixel
  71.     lis    4,Factor@ha
  72.     lfd    25,Factor@l(4)    #Get Factor into f25
  73.     lis    4,Two@ha
  74.     lfd    22,Two@l(4)    #Get Two into f22 as constant
  75.     lis    4,Limit@ha
  76.     lfd    23,Limit@l(4)    #Get Limit into f23 as constant
  77.  
  78.     fadd    14,22,22    #f14 is 4.
  79.     fadd    14,14,22    #f14 is 6.
  80.     fdiv    14,14,22    #f14 is 3.
  81.  
  82. #The above could have been done with a global definition of 3.000.
  83.  
  84.     li    30,0        #xtemp = 0.
  85.     fsub    15,22,22    #(float)xtemp = 0.
  86.     lis    4,XCenter@ha
  87.     lfd    10,XCenter@l(4)    #f10 = XCenter
  88.     fsub    15,15,10    #xRel = xRel - XCenter
  89.     fdiv    18,15,25    #xRel = xRel/Factor
  90.  
  91.     lis    4,DX@ha
  92.     lfd    21,DX@l(4)    #Get the real value of Delta x.
  93.     lis    4,RightEdge@ha
  94.     lwz    29,RightEdge@l(4)
  95.  
  96. Start:
  97.     fmr    15,18        #Initial value of Zr is xRel
  98.  
  99. #  The following line was moved before rather than after fmr f17,f16
  100. #  to give the fpu a break.
  101.     li    23,1        #Initialize CurCnt = 1
  102.     fmr    17,16        #yRel into f17 as initial Zi.
  103.     b    l3        #Check to see if to MaxCnt
  104. l2:
  105.     fmul    24,15,15    #Zr2 in f24
  106.     fmul    4,17,17    #Zi2 = Zi*Zi
  107.     fadd    19,24,4    #Zr2 + Zi2 -> f19
  108.     fcmpu    0,19,23    #Compare with Limit in f23.
  109.     ble    0,l6
  110.  
  111. #The following section is not very time-critical as it is only reached once.
  112. #for each pixel
  113.     cmpwi    0,28,2    #See if BPP < 2
  114.     blt    0,l8
  115. l7:
  116.     slwi    10,23,2    #4 times CurCnt for offset in ColorTable32
  117.     add    26,27,10    #Find location of pixel color in ColorTable32
  118.     lwz    11,0(26)    #Get ARGB from ColorTable
  119.     stw    11,0(25)    #Store color in LPixelBuf
  120.     addi    25,25,4    #Point to next location in LPixelBuf
  121.     b    l1
  122. l8:    andi.    3,23,65535    #Prep Color as UWORD for PlotIt
  123.     bl    PlotIt
  124. l9:    b    l1
  125. l6:
  126.  
  127.     fmul    20,4,14    #Zi2*3 -> f20
  128.      fmul    27,24,14    #3*Zr2 -> f27
  129.     fsub    20,24,20    #Zr2 - 3*Zi2 -> f20
  130.     fsub    27,27,4    #(3Zr2 - Zi2) -> f27
  131.     fmul    20,20,15    #Zr*(Zr2 - 3Zi2) -> f20 = Zr3
  132.  
  133.     fmul    27,27,17    #Zi*(3Zr2 - Zi2) -> f27 = Zi3
  134.     fmul    29,20,20    #Zr3*Zr3
  135.  
  136.     fmul    28,27,27    #Zi3*Zi3
  137.     fmul    30,20,27    #Zr3*Zi3
  138.     fsub    29,29,28    #Zr3*Zr3 - Zi3*Zi3 = Zr6
  139.  
  140.  
  141.     fmul    30,30,22    #2*Zr3*Zi3 = Zi6
  142.     fmul    19,30,17    #Zi*Zi6
  143.     fmul    31,29,15    #Zr*Zr6
  144.     fsub    24,31,19    #(Zr*Zr6 - Zi*Zi6) -> Zr2
  145.     fmul    29,29,17    #Zi*Zr6
  146.     fmul    30,30,15    #Zr*Zi6
  147.     fadd    17,29,30    #(Zr6*Zi + Zi6*Zr) -> Zi
  148.  
  149.  
  150.     fadd    15,18,24    #New Zr = xRel + Zr2
  151.     addi    23,23,1    #Increment CurCnt
  152.     fadd    17,16,17    #Zi = Zi + yRel
  153.  
  154. l3:
  155.     cmpw    0,23,24    #See if CurCnt < MaxCnt
  156.     blt    0,l2        #Repeat until MaxCnt reached
  157.  
  158.     cmpwi    0,28,2    #See if BPP < 2
  159.     blt    0,l11
  160. l10:
  161.  
  162.     lis    12,4
  163.     addi    12,12,-4
  164.     add    26,27,12    #Find location of pixel color
  165.     lwz    11,0(26)      #Get color
  166.  
  167.     stw    11,0(25)    #Store color in LPixelBuf
  168.     addi    25,25,4    #Point to next pixel in buffer
  169.     b    l1        #Was l12
  170. l11:
  171.     lis    11,1
  172.     addi    3,11,-1    #ffff into r3 for PlotIt
  173.     bl    PlotIt
  174. l1:
  175.     fadd    18,18,21    #Find new value of xRel (xRel = xRel + DX).
  176.     addi    30,30,1    #Increment xtemp.
  177.     cmpw    0,30,29    #See if to RightEdge
  178.  
  179.     blt    0,Start    #Repeat until row is done.
  180.     lis    4,LPixelBuf@ha
  181.     stw    25,LPixelBuf@l(4)  #New location in long pixel buffer
  182.     addi    1,1,80        #Balance Stack pointer
  183.     lwz    11,4(1)    #Get return address
  184.     mtlr    11
  185.  
  186.     blr
  187.     .type    UseLibP7,@function
  188.     .size    UseLibP7,$-UseLibP7
  189.  
  190.     .globl    MaxCnt
  191.     .globl    RightEdge
  192.     .globl    XCenter
  193.     .globl    Factor
  194.     .globl    Limit
  195.     .globl    Two
  196.     .globl    LPixelBuf
  197.     .globl    ColorTable32
  198.     .globl    BPP
  199.     .globl    DX
  200.     .globl    PlotIt
  201.  
  202.